<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>存款类型删除 - 管理后台</title>
    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.0.0/css/all.min.css">
    <style>
        * {
            margin: 0;
            padding: 0;
            box-sizing: border-box;
            font-family: 'Segoe UI', 'Microsoft YaHei', Arial, sans-serif;
        }

        body {
            min-height: 100vh;
            background: linear-gradient(135deg, #f5f7fa 0%, #e0e7ff 100%);
            display: flex;
            justify-content: center;
            align-items: center;
            padding: 20px;
        }

        .container {
            max-width: 480px;
            width: 100%;
        }

        .card {
            background: #fff;
            border-radius: 16px;
            box-shadow: 0 10px 30px rgba(0, 0, 0, 0.08);
            padding: 40px;
            transition: transform 0.3s ease, box-shadow 0.3s ease;
        }

        .card:hover {
            transform: translateY(-5px);
            box-shadow: 0 15px 40px rgba(0, 0, 0, 0.15);
        }

        .header {
            text-align: center;
            margin-bottom: 30px;
        }

        .header h2 {
            font-size: 28px;
            color: #d32f2f;
            margin-bottom: 15px;
            display: flex;
            align-items: center;
            justify-content: center;
            gap: 12px;
        }

        .header p {
            color: #666;
            font-size: 16px;
            max-width: 80%;
            margin: 0 auto;
        }

        .form-group {
            margin-bottom: 28px;
            position: relative;
        }

        .form-group label {
            display: block;
            margin-bottom: 10px;
            font-weight: 600;
            color: #444;
            font-size: 16px;
            display: flex;
            align-items: center;
            gap: 8px;
        }

        .form-group input {
            width: 100%;
            padding: 15px 18px;
            border: 1px solid #ddd;
            border-radius: 10px;
            font-size: 16px;
            transition: all 0.3s;
            background-color: #f8f9fa;
        }

        .form-group input:focus {
            border-color: #d32f2f;
            box-shadow: 0 0 0 3px rgba(211, 47, 47, 0.1);
            outline: none;
            background-color: #fff;
        }

        .warning-box {
            background: linear-gradient(to right, #fff8f8, #fef2f2);
            border-radius: 12px;
            padding: 20px;
            margin-bottom: 30px;
            border-left: 4px solid #d32f2f;
        }

        .warning-box h3 {
            font-size: 18px;
            color: #d32f2f;
            margin-bottom: 10px;
            display: flex;
            align-items: center;
            gap: 8px;
        }

        .warning-box ul {
            margin-top: 12px;
            padding-left: 20px;
        }

        .warning-box li {
            margin-bottom: 8px;
            font-size: 14px;
            color: #666;
        }

        .btn-group {
            display: flex;
            gap: 18px;
            margin-top: 18px;
        }

        .btn-delete {
            flex: 1;
            padding: 16px;
            border-radius: 10px;
            font-size: 18px;
            font-weight: 600;
            cursor: pointer;
            border: none;
            background: linear-gradient(90deg, #d32f2f 0%, #ff6b6b 100%);
            color: #fff;
            transition: all 0.3s;
            display: flex;
            align-items: center;
            justify-content: center;
            gap: 10px;
            box-shadow: 0 4px 12px rgba(211, 47, 47, 0.2);
        }

        .btn-delete:hover {
            background: linear-gradient(90deg, #b71c1c 0%, #f44336 100%);
            transform: translateY(-3px);
            box-shadow: 0 6px 20px rgba(211, 47, 47, 0.25);
        }

        .btn-delete:active {
            transform: translateY(1px);
            box-shadow: 0 2px 6px rgba(211, 47, 47, 0.2);
        }

        .btn-delete:disabled {
            background: #cccccc;
            transform: none;
            box-shadow: none;
            cursor: not-allowed;
        }

        .result-card {
            margin-top: 30px;
            background: #f8f9fa;
            border-left: 4px solid #1a3a6c;
            border-radius: 12px;
            padding: 18px 20px;
            font-size: 16px;
            color: #1a3a6c;
            display: none;
            align-items: center;
            gap: 15px;
            animation: fadeIn 0.5s ease;
        }

        .result-card.success {
            border-left-color: #2ecc71;
            background: #f0fdf4;
            color: #2ecc71;
        }

        .result-card.error {
            border-left-color: #d32f2f;
            background: #fff8f8;
            color: #d32f2f;
        }

        .result-card i {
            font-size: 22px;
        }

        .loading {
            display: inline-block;
            width: 20px;
            height: 20px;
            border: 3px solid rgba(255, 255, 255, 0.3);
            border-radius: 50%;
            border-top-color: #fff;
            animation: spin 1s ease-in-out infinite;
            margin-right: 10px;
        }

        @keyframes spin {
            to { transform: rotate(360deg); }
        }

        @keyframes fadeIn {
            from { opacity: 0; transform: translateY(10px); }
            to { opacity: 1; transform: translateY(0); }
        }

        .security-check {
            margin-top: 20px;
            padding-top: 20px;
            border-top: 1px solid #eee;
        }

        .security-check label {
            display: flex;
            align-items: center;
            gap: 10px;
            color: #444;
            font-size: 15px;
            cursor: pointer;
        }

        .security-check input {
            width: 18px;
            height: 18px;
            cursor: pointer;
        }

        .search-history {
            margin-top: 20px;
            padding: 15px;
            border: 1px solid #eee;
            border-radius: 10px;
            max-height: 200px;
            overflow-y: auto;
        }

        .history-title {
            font-weight: 600;
            margin-bottom: 10px;
            display: flex;
            align-items: center;
            gap: 8px;
        }

        .history-item {
            padding: 8px;
            border-bottom: 1px solid #f0f0f0;
            display: flex;
            justify-content: space-between;
            align-items: center;
        }

        .history-item:last-child {
            border-bottom: none;
        }

        .delete-history {
            color: #d32f2f;
            cursor: pointer;
        }

        @media (max-width: 576px) {
            .card {
                padding: 25px;
            }

            .btn-group {
                flex-direction: column;
            }

            .header h2 {
                font-size: 24px;
            }
        }
    </style>
</head>
<body>
    <div class="container">
        <div class="card">
            <div class="header">
                <h2><i class="fas fa-trash-alt"></i> 删除存款类型</h2>
                <p>此操作将永久删除存款类型，请谨慎操作</p>
            </div>

            <div class="warning-box">
                <h3><i class="fas fa-exclamation-triangle"></i> 重要提示</h3>
                <p>删除存款类型是不可逆操作，删除前请确认：</p>
                <ul>
                    <li>该存款类型已不再需要</li>
                    <li>已做好相关数据备份</li>
                    <li>该存款类型没有关联的银行卡</li>
                    <li>已获得相关管理人员的授权</li>
                </ul>
            </div>

            <div class="form-group">
                <label for="delete-depositId"><i class="fas fa-hashtag"></i> 存款ID</label>
                <input id="delete-depositId" type="number" placeholder="请输入存款类型ID">
            </div>

            <div class="security-check">
                <label>
                    <input type="checkbox" id="confirm-delete">
                    我确认已理解删除操作的后果，并确认要删除此存款类型
                </label>
            </div>

            <div class="btn-group">
                <button class="btn-delete" id="delete-btn" onclick="deleteDeposit()">
                    <i class="fa fa-trash"></i> 删除存款类型
                </button>
            </div>

            <div class="result-card" id="delete-msg">
                <i class="fa"></i>
                <span id="delete-msg-text"></span>
            </div>
        </div>
    </div>

    <script>
        // 删除存款类型函数
        function deleteDeposit() {
            const depositId = document.getElementById('delete-depositId').value.trim();
            const confirmCheckbox = document.getElementById('confirm-delete');
            const btn = document.getElementById('delete-btn');

            // 验证输入
            if (!depositId) {
                showMsg('请输入存款ID！', 'error');
                return;
            }

            // 验证确认框
            if (!confirmCheckbox.checked) {
                showMsg('请先确认删除操作！', 'error');
                return;
            }

            // 显示加载状态
            btn.innerHTML = '<div class="loading"></div>处理中...';
            btn.disabled = true;

            // 发送删除请求
            fetch(`http://localhost:8080/admin/deposit/delete?savingID=${depositId}`, {
                method: 'DELETE',
                headers: { 'Content-Type': 'application/json' }
            })
            .then(response => response.json())
            .then(data => {
                if (data.code === '200') {
                    showMsg('存款类型删除成功！', 'success');
                    // 清空输入框
                    document.getElementById('delete-depositId').value = '';
                    document.getElementById('confirm-delete').checked = false;
                } else {
                    showMsg(`删除失败：${data.message || '未知错误'}`, 'error');
                }
            })
            .catch(error => {
                showMsg(`请求失败：${error.message || '网络错误'}`, 'error');
            })
            .finally(() => {
                // 恢复按钮状态
                btn.innerHTML = '<i class="fa fa-trash"></i> 删除存款类型';
                btn.disabled = false;
            });
        }

        // 显示消息函数
        function showMsg(msg, type) {
            const card = document.getElementById('delete-msg');
            const text = document.getElementById('delete-msg-text');
            const icon = card.querySelector('i');

            card.className = type === 'success' ? 'result-card success' : 'result-card error';
            icon.className = type === 'success' ? 'fa fa-check-circle' : 'fa fa-times-circle';
            text.innerText = msg;
            card.style.display = 'flex';

            // 5秒后自动隐藏结果
            setTimeout(() => {
                if (card.style.display === 'flex') {
                    card.style.display = 'none';
                }
            }, 5000);
        }

        // 初始化页面
        document.addEventListener('DOMContentLoaded', () => {
            // 添加输入框键盘事件
            document.getElementById('delete-depositId').addEventListener('keypress', (e) => {
                if (e.key === 'Enter') {
                    deleteDeposit();
                }
            });
        });
    </script>
</body>
</html>